#include<stdio.h>

typedef struct student
{
    char name[20];
    int age;
    int ID;
}Stu;


void rea_students(const char* path,Stu* students,unsigned len)
{
    FILE* fp = fopen("path","r");
    if(fp == NULL){
        printf("error open file!");
        return ;
    }

    for(int i = 0;i < len; i++)
    {
        if(fscanf(fp,"%19s %d %d \n",students[i].name,&students[i].age,&students[i].ID) != 3)
        {
            break;// 如果读取失败或文件结束，提前退出循环
        }

    }
    fclose(fp);
}

int main( )
{
    Stu students[50];
    rea_students("/home/haiyang/wendang/test_C/25-3/3-4 .text",students,50);

    for(int i  = 0;i < 50;i++)
    {
        if(students->age == 0) break;
        printf("Student %d:\n", i+1);
        printf("Name: %s\n", students[i].name);
        printf("Age: %d\n", students[i].age);
        printf("ID: %d\n\n", students[i].ID);
    }
    return 0;
}
